﻿
# Fires when a character joins a court. Not fired for just generated characters
# Root is the character
# scope:new_employer is their new employer
# scope:old_employer is their old employer (if they had one; otherwise unset)
on_join_court = {
	events = {
		court_maintenance.0005 # Add 'Order member' trait to courtiers who join holy order court
	}
	effect = {
		shogunate_fictional_nickname_effect = yes
	}
}

# Fires when a character leaves a court. Not fired when leaving due to death or similar
# Will still fire even if on_join_court is firing (fires just before it)
# Root is the character
# scope:old_employer is their old employer
on_leave_court = {
	effect = {
		scope:old_employer = {
			every_courtier = {
				limit = { exists = var:booner_target }
				employed_booner_invalidation_effect = { EMPLOYEE = this LIEGE = scope:old_employer }
			}
			if = {
				limit = {
					is_alive = yes
					has_variable_list = halved_position_salary_employees
				}
				remove_list_variable = {
					name = halved_position_salary_employees
					target = root
				}
			}
			if = {
				limit = { 
					is_alive = yes
					has_variable_list = increased_position_salary_employees
				}
				remove_list_variable = {
					name = increased_position_salary_employees
					target = root
				}
			}
		}
		remove_variable = court_8311_cooldown
	}
	events = {
		stewardship_duty.1064 # Cancels the employment contract between this character and their former employer.
	}
}
